import { AxiosPromise } from 'axios';
import {
  AccountQuery,
  AccountVO,
  AaccountAdvertiserVO,
  AaccountAdvertiserQuery,
  ShareDpAssetManagementReq,
  ShareCancelDpAssetManagementReq,
  AccountAllCompanyInfoReq,
  AccountAllCompanyInfoResp
} from './types';
import request from '@/utils/request';

export const listAccount = (query: AccountQuery): AxiosPromise<AccountVO[]> => {
  return request({
    url: '/system/account/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询账户详细
 */
export const getAccount = (roleId: string | number): AxiosPromise<AccountVO> => {
  return request({
    url: '/system/account/' + roleId,
    method: 'get'
  });
};

/**
 * 新增账户
 */
export const addAccount = (data: any) => {
  return request({
    url: '/system/account',
    method: 'post',
    data: data
  });
};

/**
 * 修改账户
 * @param data
 */
export const updateAccount = (data: any) => {
  return request({
    url: '/system/account',
    method: 'put',
    data: data
  });
};

/**
 * 账户状态修改
 */
export const changeRoleStatus = (roleId: string | number, status: string) => {
  const data = {
    roleId,
    status
  };
  return request({
    url: '/system/role/changeStatus',
    method: 'put',
    data: data
  });
};

/**
 * 删除管理账户
 */
export const delAccount = (accountRecordIds: Array<string | number> | string | number) => {
  return request({
    url: '/system/account/' + accountRecordIds,
    method: 'delete'
  });
};
//查询账号下的广告主列表
export const getAccountAdvertiserList = (query: AaccountAdvertiserQuery): AxiosPromise<AaccountAdvertiserVO[]> => {
  return request({
    url: '/oce/third/getAccountAdvertiserList',
    method: 'get',
    params: query
  });
};

//设置小游戏&小程序共享
export const bpAssetManagementShare = (data: ShareDpAssetManagementReq) => {
  return request({
    url: '/oce/third/bpAssetManagementShare',
    method: 'post',
    data: data
  });
};
//取消小游戏&小程序共享
export const bpAssetManagementShareCancel = (data: ShareCancelDpAssetManagementReq) => {
  return request({
    url: '/oce/third/bpAssetManagementShareCancel',
    method: 'post',
    data: data
  });
};

//获取工作台（原纵横组织）下所有主体
export const getAccountAllCompanyInfo = (query: AccountAllCompanyInfoReq): AxiosPromise<AccountAllCompanyInfoResp[]> => {
  return request({
    url: '/oce/third/getAccountAllCompanyInfo',
    method: 'get',
    params: query
  });
};
